package com.xc.freeapp.util;

import javax.servlet.http.HttpServletRequest;

import com.xc.freeapp.bean.AuthInfo;

public class AuthUtil {

    private static final String AUTH_INFO_ATTRIBUTE = "AuthInfo";
    private static final String TOKEN = "Token";

    public static void setAuthInfo(HttpServletRequest request, AuthInfo authInfo) {
        request.setAttribute(AUTH_INFO_ATTRIBUTE, authInfo);
    }
    public static void setToken(HttpServletRequest request, String token) {
        request.setAttribute(TOKEN, token);
    }

    public static AuthInfo getAuthInfo(HttpServletRequest request) {
        return (AuthInfo) request.getAttribute(AUTH_INFO_ATTRIBUTE);
    }
    public static String getToken(HttpServletRequest request) {
        return (String) request.getAttribute(TOKEN);
    }

}